package abc;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;

import java.util.concurrent.TimeoutException;

import com.rabbitmq.client.Channel;
public class Send {
	 private final static String QUEUE_NAME = "hello";
	 
	public static void main(String[] args) throws java.io.IOException{
	    ConnectionFactory factory = new ConnectionFactory();
	    factory.setHost("192.168.1.101");
	    Connection connection;
	    Channel channel;
	    
		try {
			connection = factory.newConnection();
			channel = connection.createChannel();
		    channel.queueDeclare(QUEUE_NAME, false, false, false, null);
		    String message = "Hello World!";
		    channel.basicPublish("", QUEUE_NAME, null, message.getBytes());
		    System.out.println(" [x] Sent '" + message + "'");
		    channel.close();
		    connection.close();
		} catch (TimeoutException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
